[contents] [prev] [next] [top] [bottom] (4 out of 5)

ScriptX and the Core Classes

Most object-oriented languages, including ScriptX, are coupled with an extensive class library. Unlike some, however, ScriptX is a rooted language, meaning that many ScriptX values are interpreted directly as objects from this library. The ScriptX library provides a rich body of core classes containing powerful abstractions for multimedia programming. For example, there is a hierarchy of classes inheriting from the class Clock, which handles timing and synchronization. The programmer can simply use these core classes and specialize them to fit particular needs. The ScriptX core classes are described in the ScriptX Components Guide and the ScriptX Class Reference.

Being a rooted language, ScriptX was designed with the core classes library in mind. It therefore has many language constructs that know about and incorporate the methods that all objects are expected to have. The result is that ScriptX has multiple surface syntax; in other words, it often has more than one way to express the same thing. These alternate ways of expressing something, which are in many cases shortcuts for longer operations that use methods, are especially important in the areas of object creation and operator syntax. For example, StringConstant and Array are two core classes where shortcut language constructs can be used to create an instance of the class. By just entering the data which comprises a StringConstant object, you create a StringConstant object. Similarly, just entering the contents of an array in array form creates an Array object. The following are some examples showing both the shortcut language syntax and the corresponding longer version using method syntax:

Language Syntax

Equivalent Method Syntax

"I am a string"

new StringConstant \

string:"I am a string"

global ar := #(1, 2)

global ar := new Array

append ar 1

append ar 2

global kl := #(1:"one", 2:"two")

global kl := new KeyedLinkedList

append kl 1 "one"

append kl 2 "two"

The examples below demonstrate using operator syntax and array access, which are shorter and more natural than using the equivalent method syntax:

Operator Syntax

Equivalent Method Syntax

2 + 3

sum 2 3

5 * 4

mul 5 4

ar[1]

getOne ar 1

ar[1] := 2

setOne ar 1 2


This document is part of the ScriptX Language Guide, one of the volumes of the ScriptX Technical Reference Series. ScriptX is developed by the ScriptX Engineering Team at Apple Computer, successor to the Kaleida Engineering Team at Kaleida Labs, Inc.

Copyright 1996 Apple Computer, Inc. All Rights Reserved.